package model;

/**
 * The player class containing variables and methods for the players of the games.
 * @author Group 20
 *
 */
public class Player 
{
	private String name;
	private int color;
	private Konto konto = new Konto(30000);
	private int number;	
	private int standOnField;
	private boolean inJail;
	private int outOfJailCard;
	private boolean carryOn;
	private int numOfDicePairs = 0;
	

	
	/**
	 * Getter, returns number of dice pairs the player has rolled.
	 * @return numOfDicePairs: Number of pairs
	 */
	public int getNumOfDicePairs() {
		return numOfDicePairs;
	}


	/**
	 * Setter, sets the number of dice pairs.
	 * @param numOfDicePairs: number of pairs
	 */
	public void setNumOfDicePairs(int numOfDicePairs) {
		this.numOfDicePairs = numOfDicePairs;
	}


	/**
	 * Constructor, adds values for name, color and number.
	 * @param name: Player name
	 * @param color: Player color
	 * @param number: Player number
	 */
	public Player(String name, int color, int number)
	{
		this.name = name;
		this.color = color;
		this.number = number;
		this.standOnField = 1;
		this.outOfJailCard = 0;
		this.carryOn = true;
	}
	
	/**
	 * Getter, returns mayCarryOn.
	 * @return boolean value
	 */
	public boolean mayCarryOn()
	{
		return carryOn;
	}
	
	/**
	 * Setter, sets carryOn.
	 * @param carryOn: boolean value
	 */
	public void setCarryOn(boolean carryOn)
	{
		this.carryOn = carryOn;
	}
	
	/**
	 * Returns whether a player has one ore more out of jail cards.
	 * @return boolean value
	 */
	public boolean hasOutOfJailCard() {
		return outOfJailCard>0;
	}

	/**
	 * subtracts form the counter when the player spends an out of jail card.
	 * @param used: boolean value
	 */
	public void useJailCard(boolean used) {
		outOfJailCard--;
	}
	
	/**
	 * adds to the counter when recieving an out of jail card
	 */
	public void receiveJailCard()
	{
		outOfJailCard++;
	}

	/**
	 * Returns whether or not a plyer is in jail.
	 * @return boolean value
	 */
	public boolean isInJail() {
		return inJail;
	}

	/**
	 * Sets Whether the player is in jail.
	 * @param inJail: boolean value
	 */
	public void setInJail(boolean inJail) {
		this.inJail = inJail;
	}

	/**
	 * Getter, returns number.
	 * @return number: player number
	 */
	public int getNumber()
	{
		return number;
	}

	/**
	 * Getter, returns name.
	 */
	public String getName() 
	{
		return name;
	}

    /**
     * Getter, returns color.
     * @return color: player color
     */
	public int getColor() 
	{
		return color;
	}

	/**
	 * Getter, returns the players actual balance.
	 * @return player balance
	 */
	public int getBalance()
	{
		return konto.getBalance();
	}
	
	/**
	 * Setter, sets the players saldo.
	 * @param newSaldo: value for new saldo
	 */
	public void setSaldo(int newSaldo)
	{
		this.konto.setSaldo(newSaldo);
	}
	
	/**
	 * deposits to the players account equal to amount.
	 * @param amount: value for amount
	 */
	public void deposit(int amount)
	{
		konto.deposit(amount);
	}
	
	/**
	 * withdraws from the players account equal to amount.
	 * @param amount: value for amount
	 */
	public void withdraw(int amount)
	{
		konto.withdraw(amount);
	}

	/**
	 * To string method.
	 */
	@Override
	public String toString() {
		return "Player [name=" + name + ", color=" + color + ", konto=" + konto
				+ ", number=" + number + "]";
	}

	/**
	 * Getter, returns the player current position.
	 * @return standOnField: number
	 */
	public int getStandOnField() {
		return standOnField;
	}

	/**
	 * Setter, sets the players new position.
	 * @param fieldNumber: number
	 */
	public void setStandOnField(int fieldNumber) 
	{
		this.standOnField = fieldNumber;
	}
	
	
	
}
